#!/usr/bin/perl

print "> Updateing revision...\n";

system("cp configure.ac configure.ac.bak");

@INFO = `svn info`;
foreach $line (@INFO) {
    if ($line =~ /Revision: (\d+)/) {
	$REV = $1;
    }
}
print "> Revision = \"$REV\"\n";
$time = `date +%T-%d%b%C%y-%Z`;
chop $time;
print "> Time = \"$time\"\n";

$configFile = "configure.ac";
if (-e $configFile) {
    print "= Setting revision in configure.ac file\n";
}
open(CFILE,"$configFile");
@FILE = <CFILE>;
close(CFILE);

@NEWFILE;
$i = 0;

foreach $line (@FILE) {
    if ($line =~ /RELEASE=/ ) {
#	print "$line $REV\n";
	$NEWFILE[$i] = "RELEASE=\"${REV}\"\n";
    } elsif ($line =~ /BUILD_TIME=/ ) {
	#print $line;
	$NEWFILE[$i] = "BUILD_TIME=\"$time\"\n";
    }
    else {
	$NEWFILE[$i] = $line;
    }
    $i++;
}
open(CNEW,">configure.ac.new");
foreach $x (@NEWFILE) {
    print CNEW "$x";
} 
close(CNEW);

system("mv configure.ac.new configure.ac");
print "= done\n";
print "[ old configure.ac file stored as configure.ac.bak ]\n";


